<template>
	<page-meta :root-font-size="fontSize"></page-meta>
	<view>
		<view class="bg-main" style="height: 270rpx;padding:20rpx 30rpx;">
			<view class="status_bar"></view>
			<view class="flex flex-ac flex-bt fc-f">
				<h-navigateBack></h-navigateBack>
				<text style="font-size: 38rpx;">确定订单</text>
				<view></view>
			</view>
		</view>
		<view class="mg-30 bg-FF border-r-20" style="padding: 50rpx 30rpx 60rpx 30rpx; margin-top: -100rpx;">
			<view class="flex flex-bt fs-32">
				<view class="flex flex-ac">
					<image src="../static/order/up.png" style="width: 50rpx;height: 50rpx;" mode="widthFix"></image>
					<view v-if="startGeocoderAddress==''" style="margin-left: 15rpx;">{{ActualStartSiteName}}</view>
					<view v-if="startGeocoderAddress!=''" style="margin-left: 15rpx;">{{startGeocoderAddress}}</view>
					<!-- <view v-if="ActualStartTime!=''"
						style="height: 60rpx;display: flex;align-items: center;justify-content: center;margin-left: 0rpx;"
						>-{{ActualStartTime}}发车</view> -->
					<view v-if="ticketCheck.StartSites!=null&&ticketCheck.StartSites.length>1"
						style="width: 120rpx;height: 60rpx;background: linear-gradient(270deg, #FF423F, #FF763F);border-radius: 30rpx;color: #FFFFFF;display: flex;align-items: center;justify-content: center;margin-left: 5rpx;"
						@click="StationClick('start')">更换</view>
				</view>
				<view style="color: #FC4646;" class="fs-36" v-if="Price != 0">
					<text class="fs-36" style="color: #F35A46;">¥ <text
							style="font-size: 52rpx;color: #F35A46;">{{Price}}</text>
					</text>
					<!-- <text v-if="isInsure" style="font-size: 22rpx;color: #F35A46;">（含保险）</text> -->
					</text>
				</view>
			</view>
			<!-- <view style="position: absolute;border-bottom: #acb8b4 0.5px solid;width: 85%;margin-top: 15rpx;"></view> -->
			<view class="flex flex-ac fs-32" style="margin-top: 30rpx;">
				<image src="../static/order/down.png" style="width: 50rpx;height: 50rpx;" mode="widthFix"></image>
				<!-- <view  style="margin-left: 20rpx;">{{ActualEndSiteName}}</view> -->
				<view v-if="endGeocoderAddress==''" style="margin-left: 15rpx;">{{ActualEndSiteName}}</view>
				<view v-if="endGeocoderAddress!=''" style="margin-left: 15rpx;">{{endGeocoderAddress}}</view>
				<!-- <view v-if="ActualEndTime!=''"
					style="height: 60rpx;display: flex;align-items: center;justify-content: center;margin-left: 0rpx;"
					>-{{ActualEndTime}}到达</view> -->
				<view v-if="ticketCheck.EndSites!=null&&ticketCheck.EndSites.length>1"
					style="width: 120rpx;height: 60rpx;background: linear-gradient(270deg, #FF423F, #FF763F);border-radius: 30rpx;color: #FFFFFF;display: flex;align-items: center;justify-content: center;margin-left: 5rpx;"
					@click="StationClick('end')">更换</view>
			</view>
			<view
				v-if="ticketCheck.EndSites!=null&&ticketCheck.EndSites.length>1||ticketCheck.StartSites!=null&&ticketCheck.StartSites.length>1"
				class="jh_u-f-ajb" style="margin-top: 30rpx;">
				<view class="jh_fs_26" style="color: #FF4848;">定制班车,可选择更换按钮就近站点上车</view>
			</view>
			<view v-if="ticketCheck.StartSites!=null&&ticketCheck.StartSites.length>1" class="jh_u-f-ajb"
				style="margin-top: 30rpx;">
				<view class="jh_fs_26" style="color: #FF4848;">{{recommendGeton}}</view>
			</view>
		</view>
		<view v-if="HotLine" class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF"
			@click="HotLineClick(HotLine)">
			<view class="fs-30">热线号码</view>
			<view class="jh_u-f-ac">
				<text style="font-size: 30rpx;">{{HotLine}} <text
						style="margin-left: 15rpx;border-radius: 10rpx;background-color: #007AFF;color: #FFFFFF;padding: 10rpx;">拨打热线</text>
				</text>
			</view>
		</view>
		<view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF"
			style="font-weight: 900;font-size: 120%;" @click="scheduleShow">
			<view class="fs-30" style="font-size: 120%">班次时刻</view>
			<view class="jh_u-f-ac">
				<text v-if="ticketCheck.SetoutTime">{{getTicketDate(ticketCheck.SetoutTime)}}</text>
				<u-icon name="arrow-right" color="#999" size="32"></u-icon>
			</view>
		</view>
		<view  class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">班次号</view>
			<view class="jh_u-f-ac">
				<text>{{ticketCheck.PlanScheduleCode}}</text>
				<u-icon name="arrow-right" color="#999" size="32"></u-icon>
			</view>
		</view>
		<view v-if="EstimatedTime>0" class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">预计运行时长</view>
			<view class="jh_u-f-ac">
				<text>{{EstimatedTime}}分钟</text>
				<u-icon name="arrow-right" color="#999" size="32"></u-icon>
			</view>
		</view>
		<view class=" mg-30 mg-top-20 pd-30 border-r-20 bg-FF" style="letter-spacing: 4rpx;">
			<view class="jh_u-f-ajb">
				<view class="fs-32 fw-700">选择乘客</view>
				<view @click="addFreeChild" v-if="!isSBus" style="color: #2979ff;">
					{{freeChildtitle}}
					<u-icon name="arrow-right" color="#2979ff" size="28"></u-icon>
				</view>
				<!-- <view @click="addPassage">
					<u-icon name="plus" color="#2979ff" size="28"></u-icon>
				</view> -->
			</view>
			<view class="flex flex-ac flex-jc mg-top-40" v-if="personArr.length==0" @click="selectPassage()">
				<view
					style="width: 310rpx;text-align: center;padding: 20rpx;color:#FF4848 ;border: solid 1rpx #FF4848;border-radius: 20rpx;"
					hover-class="u-hover-class">+添加乘客</view>
			</view>
			<view class="flex flex-ac flex-bt mg-top-40" v-if="personArr.length>0">
				<view class="ellipsis flex flex-ac" style="width: 500rpx;">
					<view class="fs-30 border-r-8 v-name" v-for="(item, index) in personArr" :key="index">
						{{ item.Name }}
					</view>
				</view>
				<view class="fc-999 fs-30" @click="selectPassage">
					更多
					<u-icon name="arrow-right" color="#999" size="32"></u-icon>
				</view>
			</view>
			<view class="flex flex-ac flex-bt mg-top-40 fs-32" v-for="(item, index) in personArr" :key="index">
				<view>
					<view>
						{{ item.Name }}
						<text class="border-r-8 v-type">{{ item.Type }}</text>
					</view>
					<view class="fc-999 fs-26 mg-top-20">身份证：{{$h.method.getIdCardTurn(item.IDCard)}}</view>
				</view>
				<view
					style="width: 120rpx;height: 60rpx;background: linear-gradient(270deg, #FF423F, #FF763F);border-radius: 30rpx;color: #FFFFFF;display: flex;align-items: center;justify-content: center;"
					@click="passageDelete(index)">删除</view>
			</view>
		</view>
		<view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">联系电话</view>
			<input placeholder-class="placeholderclass" type="number" placeholder="请输入手机号码"
				style="width: 300rpx;text-align: right;" maxlength="11" v-model="phone" />
		</view>
		<!-- <view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">备注</view>
			<input placeholder-class="placeholderclass" type="text" placeholder="请输入备注信息"
				style="width: 300rpx;text-align: right;" v-model="remark" />
		</view> -->
		<!-- <view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">优惠券</view>
			<view class="fc-999">
				无可用
				<u-icon name="arrow-right" color="#999" size="32"></u-icon>
			</view>
		</view> -->
		<view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF" v-if="isInsureType">
			<view class="fs-30">
				购买乘车险
				<text class="fs-32" style="margin-left: 10rpx;color: #FC4646;">{{insurance}}元/人</text>
			</view>
			<view class="checkbox" :class="isCheckInsurance ? 'checkbox-activite' : ''" @click="insuranceSelect(true)">
				<u-icon name="checkmark" color="#FFF" size="32"></u-icon>
			</view>
		</view>
		<!-- 同意购票须知 -->





		<view class="flex flex-ac flex-bt mg-30 mg-top-20 pd-30 border-r-20 bg-FF">
			<view class="fs-30">
				我已阅读并同意条款
				<text v-if="isCheckInsurance">与责任免除</text>
				<text v-if="isCheckInsurance" style="margin-left: 10rpx;color: #19A0FF;"
					@click="showInsureContent">《投保人声明》</text>
				<text style="margin-left: 10rpx;color: #19A0FF;" @click="showNoticeContent">《购票须知》</text>
			</view>
			<view class="checkbox" :class="isCheckNotice ? 'checkbox-activite' : ''"
				@click="isCheckNotice = !isCheckNotice">
				<u-icon name="checkmark" color="#FFF" size="32"></u-icon>
			</view>
		</view>
		<view style="height: 120rpx;"></view>
		<!-- 立即支付 -->
		<view class="flex flex-ac flex-bt bg-FF" style="position: fixed;bottom: 0;left: 0;right: 0;">
			<view class="flex flex-ac flex-bt" style="padding: 35rpx 40rpx 35rpx 45rpx;width: 60%;">
				<view style="font-size: 38rpx;color:#FC4646 ;"><!-- ￥{{totalPrice}} -->
					<text class="fs-38" style="color: #F35A46;">¥ <text
							style="font-size: 52rpx;color: #F35A46;">{{totalPrice}}</text> <text
							style="font-size: 22rpx;color: #F35A46;" v-if="isCheckInsurance">（含保险）</text>
					</text>
				</view>
				<view class="fs-30" style="line-height: 30rpx;" v-if="false">
					明细
					<u-icon name="arrow-up" size="30" color="#999" style="padding-left: 10rpx;"></u-icon>
				</view>
			</view>
			<view class="flex flex-ac flex-jc bg-main fs-34 fc-f" :class="isCheckNotice ? '' : 'defaultPay' "
				style="height: 100%;padding: 35rpx 0;width: 40%;" hover-class="u-hover-class"
				:style="{background:ticketCheck.length == 0 ? 'linear-gradient(270deg, #95a5a6, #bdc3c7)' : 'linear-gradient(270deg, #FF763F, #FF423F)'}"
				@click="submitOrder">立即支付
			</view>
		</view>
		<!-- 弹出层：车票数据 -->
		<u-popup v-model="showTimePick" mode="bottom" border-radius="14">
			<view style="padding: 40rpx 45rpx;height: 1000rpx;">
				<view class="flex flex-ac flex-bt">
					<view class="fw-700" style="font-size: 42rpx;letter-spacing: 2rpx;">选择乘车时间</view>
					<u-icon name="close" size="34" @click="showTimePick=false"></u-icon>
				</view>
				<!-- <view class="bg-FF" style="margin-top: 20rpx;"><u-tabs :list="list" font-size="32" :current="current" active-color="#F35A46" @change="change"></u-tabs></view> -->
				<!-- 时间选项卡 -->
				<view class="headerClass">
					<scroll-view class="scrollClass" scroll-x :scroll-into-view="scrollToView"
						scroll-with-animation="true">
						<view class="blockClass" :class="selectIndex == index ? 'dateselect': '' "
							v-for="(item,index) in dateArray" :key="index" @click="dateClick(index,item)"
							v-model="selectIndex">
							<view class="textCLass jh_fs_26" :id="'view' + index">
								<view class="weekClass" :style="{color:selectIndex == index ? '#FFFFFF' : '#333333'}">
									{{item.week}}
								</view>
								<view class="dateClass" :style="{color:selectIndex == index ? '#FFFFFF' : '#333333'}">
									{{item.date}}
								</view>
							</view>
						</view>
					</scroll-view>
					<view style="width: 14%;height: 100%; align-items: center; justify-content: center;display: flex;">
						<image src="../static/order/calendar.png" class="calendarImage" @click="onShowDatePicker()">
						</image>
					</view>
				</view>

				<scroll-view style="height: 800rpx;" :scroll-y="true">
					<view class="flex flex-bt flex-ac"
						style="border-bottom: solid 1rpx #DCDCDC;padding: 40rpx 10rpx 30rpx 10rpx;"
						v-for="(item,index) in shiftList" :key="index">
						<view class="flex flex-ac">
							<view style="margin-left: 15rpx;" @click="ticketSelect(index)">
								<view>
									<view class="fc-main fs-36" style="display: flex;align-items: center;">
										<image src="../../static/order/xianlu.png" style="width: 35rpx;height: 35rpx;">
										</image>
										<view style="margin-left: 10rpx;font-size: 34rpx;">{{item.LineName}}</view>
									</view>
									<view class="fc-main fs-36"
										style="display: flex;align-items: center;flex-direction: column;">
										<view class="fc-main fs-36"
											style="display: flex;align-items: center;margin-top: 5rpx;">
											<view class="jh_u-f-ac">
												<image src="../static/order/time.png"
													style="width: 35rpx;height: 35rpx;">
												</image>
												<view style="margin-left: 10rpx;">{{timeFormat(item.SetoutTime)}}</view>
											</view>
											<text class="fs-30" style="margin-left: 30rpx;color: #F35A46;">¥ <text
													style="font-size: 40rpx;color: #F35A46;">{{item.FullPrice}}</text>
											</text>
											<view class="jh_u-f-ac" style="margin-left: 30rpx;">
												<image src="../static/order/freeTicket.png"
													style="width: 42rpx;height: 32rpx;"></image>
												<text
													style="margin-left: 10rpx;">{{item.CoachSeatNumber}}座/余{{item.FreeSeats}}张</text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</view>
						<view class="checkbox" :class="item.checked ? 'checkbox-activite' : ''"
							@click="ticketSelect(index)">
							<u-icon name="checkmark" color="#FFF" size="32"></u-icon>
						</view>
					</view>
					<u-empty text="无班次信息" v-if="shiftList.length == 0"></u-empty>
				</scroll-view>
			</view>
			<view class="bg-main fc-f fs-34" hover-class="u-hover-class" @click="ticketConfirm"
				style="text-align: center;padding: 30rpx 0 ;margin: 10rpx 60rpx 0 60rpx;border-radius: 200rpx;">
				确定
			</view>
			<view style="height: 30rpx;"></view>
		</u-popup>
		<!-- 弹出层：查看须知 -->
		<u-popup v-model="showNotice" mode="bottom" border-radius="14">
			<view
				style="height: 1240rpx; padding: 40rpx;display: block;line-height: 38rpx;margin: 32rpx 0;font-size: 30rpx;">
				<u-parse :html="noticeContent"></u-parse>
				<view class="bg-main fc-f fs-34" hover-class="u-hover-class" @click="comfirmGPXZinfo"
					style="text-align: center;padding: 20rpx 0 ;margin: 10rpx 60rpx 0 60rpx;border-radius: 200rpx;">
					同意购票须知
				</view>
			</view>
		</u-popup>
		<!-- 弹出层：免费携童 -->
		<u-popup v-model="showFreeChild" mode="bottom" border-radius="14" :safe-area-inset-bottom="true">
			<view style="background-color: #ecf0f1;">
				<view class="jh_u-f-ajb"
					style="height: 100rpx;width: 100%;background-color: #FFFFFF;padding: 0 20rpx 0 20rpx;">
					<view style="color: #000000;font-size: 30rpx;font-weight: bolder;" @click="showFreeChild = false">取消
					</view>
					<view style="color: #2979ff;font-size: 30rpx;font-weight: bolder;" @click="freeChildConfirm">确定
					</view>
				</view>
				<view style="width: 100%;height: 720rpx;background-color: #ecf0f1;">
					<!-- <view class="jh_u-f-ajc" style="font-size: 25rpx;color: #95a5a6;height: 80rpx;">携童票占班车总座位的10%，此班次剩余<text style="color: #e74c3c;">5</text>张</view> -->
					<view class="jh_u-f-ajb"
						style="width: 90%;margin-left: 5%;margin-right: 5%;height: 160rpx;background-color: #FFFFFF;padding: 0 40rpx 0 40rpx;margin-top: 40rpx;">
						<view>
							<view style="font-size: 38rpx;">携童票</view>
							<view style="font-size: 32rpx;color: #000;">免费申请，无座位</view>
						</view>
						<u-number-box v-model="freeValue" button-size="100" color="#000" :min="0" disabled-input='true'
							:max="freeMax" @change="freeValChange"></u-number-box>
					</view>
					<view style="padding: 30rpx;display: block;line-height: 45rpx;margin: 32rpx 0;font-size: 25rpx;">
						<u-parse :html="noticeContent"></u-parse>
					</view>
				</view>
			</view>
		</u-popup>
		<u-toast ref="uToast"></u-toast>
		<!-- 日历 -->
		<uni-calendar ref="calendar" lunar="true" :insert="false" @confirm="confirm"></uni-calendar>
		<!-- #ifdef MP-WEIXIN -->
		<jh-authorize></jh-authorize>
		<!-- #endif -->
	</view>
</template>
<script>
	import {
		callWithErrorHandling
	} from "vue";
	var _self;
	import jhAuthorize from '@/components/jh-authorize/jh-authorize.vue';
	var app = getApp().globalData;
	export default {
		components: {
			jhAuthorize
		},
		data() {
			return {
				personArr: [],
				phone: '', //联系电话
				remark: '', //备注
				isCheckInsurance: false,
				isSBus: false,
				insurance: 2, //保险价格
				isInsure: false,
				isInsureType: false,
				SchedulesType: [],
				isCheckNotice: false,
				showNotice: false,
				showFreeChild: false,
				showTimePick: false,
				freeValue: 1,
				scrollToView: '',
				date: '', //时间轴上选中的日期
				recommendGeton: '', //推荐上车点
				list: [{
						name: '今天'
					},
					{
						name: '明天'
					},
					{
						name: '后天'
					}
				],
				current: 0,
				fontSize: '', //字体大小
				orderInfo: [], //订单信息
				startStation: '', //起点--接口查询字段
				endStation: '', //终点--接口查询字段
				startGeocoderAddress: '', //实际上车点
				endGeocoderAddress: '', //实际下车点
				ActualStartSiteName: '', //起点--推荐上车字段
				ActualEndSiteName: '', //终点--推荐下车字段
				ActualStartTime: '',
				ActualEndTime: '',
				EstimatedTime: 0,
				PlanStartSiteName: '', //乘客选择字段
				PlanEndSiteName: '', //乘客选择字段
				userInfo: [], //用户信息
				ticketNum: 0, //票数
				idNameTypeStr: '', //乘客信息：拼接成字符串
				childrenNum: 0, //携童数
				adultNum: 0, //成人数
				freeTicketNum: 0, //免票数
				addOrderInfo: [], //添加订单
				paymentData: [], //支付信息数组
				timer: '', //定时器
				dateArray: [], //时间轴数组
				selectIndex: '', //选中下标
				dateShow: false, //是否显示日历
				shiftList: [], //班次列表
				Price: 0, //顶部显示的价格
				totalPrice: 0, //总价
				PriceID: '', //价格ID，下单时需要
				ticketCheck: [], //确认
				startLineSite: [], //上车点数组
				currentLongitude: '', //乘客当前经度
				currentLatitude: '', //乘客当前纬度
				openid: '',
				LinePrices: [],
				LineID: '',
				FullPrice: '',
				HalfPrice: '',
				noticeContent: '',
				flowID: '', //支付流程ID
				checkTicketTimer: '', //确认订单状态定时器
				HotLine: '', //热线
				BookType: '', //记录当前是城际快车还是汽车票
				isStationChange: false, //判断是否有更换站点，站点更换之后做不一样的发车提示
				freeMax: 1,
				freeCountChange: 1,
				freeCount: 0, //携童免票数量
				freeChildtitle: '免费携童',
				CarryChildAvaliable: false, //是否可以携童
				StartSiteLoction: '', //上车点经纬度
				EndSiteLoction: '', //下车点经纬度
				ticketCheckPriceID: '',
				recallId: '',
				sequence: '',
				params: [],
				// isOtherSystemName: '',
			};
		},
		onLoad(params) {
			_self = this;
			_self.params = params;
			console.log('111', params);
			//设置页面字体大小
			_self.fontSize = app.fontSize;
			//初始化时间轴
			_self.loadDate();
			//判断用户是否登陆
			_self.judgeUserInfo();
			_self.successPay();
			// params.startStation = '延平';
			// params.endStation = '建瓯';
			//保险页面回调
			if (params.selectDate != undefined) {
				// _self.ticketCheck = JSON.parse(params.ticketCheck);
				_self.phone = params.phoneNumber;
				_self.startStation = params.startStation;
				_self.endStation = params.endStation;

				//推荐上车字段
				_self.ActualStartSiteName = params.StartSiteName;
				_self.ActualEndSiteName = params.EndSiteName;
				// _self.endGeocoderAddress=_self.ActualEndSiteName;//实际下车名字
				_self.PlanStartSiteName = params.StartSiteName;
				_self.PlanEndSiteName = params.EndSiteName;
				//接收上一个页面传过来的时间
				_self.date = params.selectDate;
				_self.BookType = params.type;
				//将上一个页面传过来的日期设置为被选中状态
				if (params.ticketCheckPriceID != undefined) {
					_self.ticketCheckPriceID = params.ticketCheckPriceID;
					_self.isCheckInsurance = true;
					_self.isInsureType = true;
					_self.sequence = params.sequence;
					_self.recallId = params.recallId;
				} else if(_self.BookType !=  '校园直通车' ){
					_self.showTimePick = true;
					_self.BookType = params.type + ',光泽特产'
					// _self.isOtherSystemName = '光泽特产';
				}
				else if (_self.BookType == '校园直通车') {
					_self.isSBus = true;
				}

			} else {
				//班次信息
				// 数据格式{"selectDate": "2021/10/26","startStation": "延平","endStation": "南平建阳站"}
				uni.removeStorageSync('freeCount');
				_self.orderInfo = JSON.parse(params.stationInfo);
				console.log('000', _self.orderInfo);
				//接口查询字段
				_self.startStation = _self.orderInfo.startStation;
				_self.endStation = _self.orderInfo.endStation;
				//推荐上车字段
				_self.ActualStartSiteName = _self.orderInfo.startStation;
				_self.ActualEndSiteName = _self.orderInfo.endStation;
				// _self.endGeocoderAddress=_self.ActualEndSiteName;//实际下车名字
				_self.PlanStartSiteName = _self.orderInfo.startStation;
				_self.PlanEndSiteName = _self.orderInfo.endStation;
				//接收上一个页面传过来的时间
				_self.date = _self.orderInfo.selectDate;
				//一进页面就弹出时刻表
				_self.showTimePick = true;
				_self.BookType = _self.orderInfo.type;
				_self.LineID = _self.orderInfo.LineID;
				//将上一个页面传过来的日期设置为被选中状态
			}
			_self.onSelected(_self.date);
		},
		onShow() {
			//获取用户信息
			// _self.userInfo = uni.getStorageSync('userInfo');
			//判断用户是否登陆
			// _self.judgeUserInfo();
			//获取乘车人信息
			_self.getPassageInfo();
			uni.getStorage({
				key: 'WXOpenID',
				success(res) {
					_self.openid = res.data;
				},
			})
			_self.successPay();

		},
		onUnload() {
			clearInterval(_self.timer);
			clearInterval(_self.checkTicketTimer);
		},
		methods: {
			//-----------------------------------------------Toast 消息提示-----------------------------------------------
			showToast(title, type) {
				_self.$refs.uToast.show({
					title: title,
					type: type,
				})
			},
			//-----------------------------------------------携童数量改变-----------------------------------------------
			freeValChange: function(value) {
				//添加携童数,携童数不能大于乘客数
				if (value.value > _self.adultNum) {
					_self.showToast('携童数已达上限', 'warning');
				} else {
					_self.freeCountChange = value.value;
				}
			},
			//-----------------------------------------------携童数量确定-----------------------------------------------
			freeChildConfirm: function() {
				_self.showFreeChild = false;
				_self.freeChildtitle = '';

				_self.freeCount = _self.freeCountChange;
				
				uni.setStorageSync('freeCount', _self.freeCount);
				if (_self.freeCount == 0) {
					_self.freeChildtitle = '免费携童';
				} else {
					_self.freeChildtitle = '免费携童数' + _self.freeCount + '位';
				}
				//添加携童之后，重新计算乘客
				_self.countPassage(_self.personArr);
			},
			/**
			 * 身份证加*号
			 */
			idCardChange(str) {
				if (str == null || str == '') return '';
				return str.substr(0, 2) + '**************' + str.substr(str.length - 2, str.length);
			},
			comfirmGPXZinfo: function() {
				if (!_self.isCheckNotice) {
					_self.isCheckNotice = true;
				}
				_self.showNotice = false;
				_self.submitOrder();
			},
			successPay: function() {
				uni.getStorage({
					key: 'successPay',
					success(res) {
						if (res.isSuccessPay) {
							//保险业务跳转出票H5页面
							if (res.recallId != '') {
								var CallbackParams = {
									flowID: res.flowID,
									recallId: res.recallId,
									sequence: res.sequence,
								}
								uni.redirectTo({
									url: '/pages_IntercityExpress/subWebViewItem/BaseCallbackView?CallbackParams=' +
										JSON
										.stringify(
											CallbackParams)
								})

							} else {
								_self.checkTicketTimer = setInterval(function() {
									//支付成功之后继续调获取支付参数的接口，查询订单状态
									_self.checkTicketState(res.flowID);
								}, 2000)
							}
						}
					},
				})
			},
			//-------------------------------------------判断用户是否登陆-------------------------------------------
			judgeUserInfo: function() {
				console.log(123);
				uni.getStorage({
					key: 'userInfo',
					success: function(res) {
						_self.userInfo = res.data;
						if (!res.data.PhoneNumber) {
							uni.showModal({
								title: '温馨提示',
								content: '未绑定手机号，是否立即绑定？手机号将用于获取短信信息。',
								success(res) {
									if (res.confirm) {
										_self.bindPhoneNum();
									}
								}
							})
						}
						//填写本人手机号
						if (!_self.phone) {
							_self.phone = _self.userInfo.PhoneNumber;
						}
					},
					fail: function() {
						// #ifdef APP
						uni.navigateTo({
							url: '../../pages/Login/Login'
						});
						// #endif
						// #ifdef MP-WEIXIN
						uni.$emit('getAuthorize', {
							data: '授权'
						});
						// #endif

					}
				})
			},
			//-------------------------------------------绑定手机号-------------------------------------------
			bindPhoneNum: function() {
				uni.showModal({
					title: '绑定手机号',
					editable: true,
					placeholderText: '请输入手机号',
					success(res) {
						if (res.confirm) {
							if (res.content) {
								if (res.content.length != 11) {
									_self.showToast('手机号有误，请重新输入', 'warning');
								} else {
									uni.getStorage({
										key: 'WXOpenID',
										success(openidData) {
											_self.GetUserByPhoneNumber(res.content, openidData.data);
										}
									})
								}
							} else {
								_self.showToast('手机号为空，绑定失败', 'error');
							}
						}
					}
				})
			},
			//-------------------------------绑定手机号---------------------------------
			GetUserByPhoneNumber: function(PhoneNumber, openid) {
				uni.showLoading({
					title: '正在绑定手机号...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetUserByPhoneNumber.url,
					method: _self.$h.expressInterface.expressInterface.GetUserByPhoneNumber.method,
					header: _self.$h.expressInterface.expressInterface.GetUserByPhoneNumber.header,
					data: {
						PhoneNumber: PhoneNumber,
						openid: openid
					},
					success: (res) => {
						uni.hideLoading();
						if (res.data.Success) {
							var arr = JSON.parse(res.data.Data);
							var userArr = {
								Id: arr.AID,
								NickName: arr.NickName,
								OpenId: openid,
								PhoneNumber: arr.PhoneNumber,
								SystemName: arr.SystemName,
								Name: arr.NickName,
								avatarUrl: _self.userInfo.avatarUrl
							}
							uni.setStorageSync('userInfo', userArr);
							_self.userInfo = userArr;
							_self.showToast('绑定手机号成功', 'success');
						} else {
							_self.showToast('绑定失败，请稍后重新绑定', 'error');
						}
					},
					fail(res) {
						uni.hideLoading();
						_self.showToast('绑定失败，请稍后重新绑定', 'error');
					}
				});
			},
			getInsurePay: function(params) {

				_self.ActualStartSiteName = params.StartSiteName;
				_self.startGeocoderAddress = '';
				_self.endGeocoderAddress = '';
				let SiteNames = params.StartSiteName.split(',');
				if (SiteNames.length > 1) {
					_self.ActualStartSiteName = SiteNames[0];
					_self.startGeocoderAddress = SiteNames[1];
				}
				_self.changeTicketPrice();

				//调起支付
				_self.GetFlowIdByParam();
			},
			//-------------------------------------------更换上下车点-------------------------------------------
			StationClick: function(type) {
				uni.$on('mapStartStaionChange', function(data) {
					if (data) {
						_self.ActualStartSiteName = data.StationName;
						_self.startGeocoderAddress = data.startGeocoderAddress,
							_self.StartSiteLoction = data.startLongLat;
						_self.isStationChange = true;
						_self.changeTicketPrice();
					}
					//清除监听，不清除会消耗资源 
					uni.$off('mapStartStaionChange');
				});
				uni.$on('mapEndStaionChange', function(data) {
					if (data) {
						_self.ActualEndSiteName = data.StationName;
						console.log('113', _self.ActualEndSiteName);
						_self.endGeocoderAddress = data.endGeocoderAddress,
							_self.EndSiteLoction = data.endLongLat;
						_self.isStationChange = true;
						_self.changeTicketPrice();
					}
					//清除监听，不清除会消耗资源
					uni.$off('mapEndStaionChange');
				});
				if (_self.ticketCheck.length != 0) {
					var selectStation = '';
					if (type == 'start') {
						selectStation = _self.ActualStartSiteName;
					} else {
						selectStation = _self.ActualEndSiteName;
					}
					uni.navigateTo({
						url: '../mapPoint/mapPointPicker?stationList=' + encodeURIComponent(JSON.stringify(
								_self.ticketCheck)) + '&type=' + type + '&PriceID=' + _self.PriceID +
							'&selectStation=' + selectStation
					})
				} else {
					_self.showToast('请先选择班次', 'warning');
				}
			},
			//-------------------------------------------更换上下车点之后筛选价格-------------------------------------------
			changeTicketPrice: function() {
				if (_self.LinePrices != null && _self.LinePrices.length > 0) {
					var ticketPriceChange = [];
					console.log('00', _self.LinePrices);
					console.log('11', _self.ActualStartSiteName, _self.ActualEndSiteName);
					if (_self.ticketCheckPriceID == '') {
						ticketPriceChange = _self.LinePrices.filter(item => {
							return _self.ActualStartSiteName == item.StartSiteName && _self
								.ActualEndSiteName == item.EndSiteName
						})
					} else {
						ticketPriceChange = _self.LinePrices.filter(item => {
							return _self.ActualStartSiteName == item.StartSiteName && _self
								.ActualEndSiteName ==
								item.EndSiteName && _self.PriceID == item.PriceID
						})
					}
					if (ticketPriceChange.length > 0) {
						console.log(ticketPriceChange);

						_self.ActualStartSiteName = ticketPriceChange[0].StartSiteName;
						_self.ActualEndSiteName = ticketPriceChange[0].EndSiteName;
						_self.PlanStartSiteName = ticketPriceChange[0].StartSiteName;
						_self.PlanEndSiteName = ticketPriceChange[0].EndSiteName;
						_self.FullPrice = ticketPriceChange[0].FullPrice;
						_self.HalfPrice = ticketPriceChange[0].HalfPrice;
						_self.Price = ticketPriceChange[0].FullPrice;
						_self.PriceID = ticketPriceChange[0].PriceID;
						// _self.ActualStartTime = _self.timeFormat(ticketPriceChange[0].SetoutTime) ;
						// _self.ActualEndTime = _self.timeFormat(this.$u.timeFormat(new Date(new Date(ticketPriceChange[0].SetoutTime).getTime()+60*1000*_self.EstimatedTime), 'yyyy-mm-ddThh:MM:ss'));
						_self.ticketCheck.SetoutTime = ticketPriceChange[0].SetoutTime;
						var time = _self.timeFormat(ticketPriceChange[0].SetoutTime);
						if (_self.isStationChange) {
							_self.showToast('发车时间已变更，当前发车时间为：' + time + '，上车站点：' + _self.ActualStartSiteName +
								'，下车站点：' + _self.ActualEndSiteName, 'success');
						} else {
							_self.showToast('当前发车时间为：' + time + '，上车站点：' + _self.ActualStartSiteName + '，下车站点：' + _self
								.ActualEndSiteName, 'success');
						}
						_self.countTotalPrice();
					} else {
						setTimeout(function() {
							uni.showModal({
								title: '温馨提示',
								content: '暂无' + _self.ActualStartSiteName + '-' + _self
									.ActualEndSiteName + '的票价，请重新选择',
								success(res) {

								}
							})
							_self.ActualStartSiteName = _self.PlanStartSiteName;
							_self.ActualEndSiteName = _self.PlanEndSiteName;
						}, 500)
					}
				}
			},
			//-------------------------------时间转换-------------------------------
			timeFormat(date) {
				var setTime = date.split('T')[1];
				return setTime.substring(0, 5);
			},
			getTicketDate: function(date) {
				var setTime = date.replace('T', ' ');
				return setTime.substring(0, 16);
			},
			//--------------------------------------------读取乘车人信息--------------------------------------------
			getPassageInfo: function() {
				_self.childrenNum = 0;
				_self.adultNum = 0;
				_self.freeTicketNum = 0;
				uni.getStorage({
					key: 'freeCount',
					success: function(data) {
						_self.freeCount = data.data;
						if (_self.freeCount == 0) {
							_self.freeChildtitle = '免费携童';
						} else {
							_self.freeChildtitle = '免费携童数' + _self.freeCount + '位';
						}
					},
					fail() {
						_self.freeCount = 0;
						 //_self.showToast('获取携童信息失败，请重新下单', 'error');
					}
				})
				uni.getStorage({
					key: 'personList',
					success: function(data) {
						if (_self.isSBus) {
							for (let i = 0; i < data.data.length; i++) {
								if (data.data[i].Type != '成人') {
									_self.personArr = [];
									_self.showToast('校园直通车不享受儿童免费乘车或者客票半价优待,请重新选择乘车人!', 'error');
									break;
								} else {
									_self.personArr = data.data;
								}
							}
						} else {
							_self.personArr = data.data;
						}
						_self.idNameTypeStr = '';
						if (_self.personArr.length > 0) {
							_self.countPassage(data.data);
						}
					},
					fail() {
						// _self.showToast('获取乘客信息失败', 'error');
					}
				});
			},
			//--------------------------------------------计算乘车人数--------------------------------------------
			countPassage: function(passageArr) {
				_self.childrenNum = 0;
				_self.adultNum = 0;
				_self.freeTicketNum = 0;
				_self.idNameTypeStr = '';
				if (passageArr.length == 0) _self.totalPrice = 0;
				for (let i = 0; i < passageArr.length; i++) {
					var type = '';
					if (passageArr[i].Type == '免票儿童') {
						type = 2;
					} else if (passageArr[i].Type == '成人') {
						type = 0;
					} else if (passageArr[i].Type == '半票儿童') {
						type = 1;
					}
					//拼接id name type：拼接乘客数据
					_self.idNameTypeStr += passageArr[i].IDCard + ',' + passageArr[i].Name + ',' + type + '|';
					_self.ticketNum++;
					//把儿童票筛选出来
					if (passageArr[i].Type == '半票儿童') {
						_self.childrenNum++;
					} else if (passageArr[i].Type == '成人') {
						_self.adultNum++;
					} else if (passageArr[i].Type == '免票儿童') {
						_self.freeTicketNum++;
					}
				}
				//拼接免票携童
				if (_self.freeCount > 0) {
					for (var i = 0; i < _self.freeCount; i++) {
						_self.idNameTypeStr += '出生证' + "," + Math.floor(Math.random() * 999999) + "," + '免票儿童' + "," +
							"2|";
					}
				}
				//把最后面的'｜'去掉
				// _self.idNameTypeStr = _self.idNameTypeStr.substring(0, _self.idNameTypeStr.length - 1);
				_self.idNameTypeStr = _self.idNameTypeStr;
				if (_self.ticketCheck.length != 0) {
					//计算总票价
					_self.countTotalPrice();
				}
			},
			sendTemMessage() {
				///发起消息订阅
				uni.requestSubscribeMessage({
					tmplIds: ['tF20uPdhliRv9ZsNeQm5hrVJ7UDbpVcwToKdSAZGmuM',
						'8hM-0Pc96LlXHWy91NwZTwcnwAOqSjYTEYPynyO-yrE',
						'abUi0tgJ_sT1zgvS9PEh-C_tcAGcX4O3Gutjx5sfdq8'
					], //这里填入我们生成的模板id
					success: (res) => {
						if (res['tF20uPdhliRv9ZsNeQm5hrVJ7UDbpVcwToKdSAZGmuM',
								'8hM-0Pc96LlXHWy91NwZTwcnwAOqSjYTEYPynyO-yrE',
								'abUi0tgJ_sT1zgvS9PEh-C_tcAGcX4O3Gutjx5sfdq8'] === 'accept') {
							// wx.showToast({
							// 	title: '订阅成功！',
							// 	icon: 'success'
							// })
						} else if (res['tF20uPdhliRv9ZsNeQm5hrVJ7UDbpVcwToKdSAZGmuM',
								'8hM-0Pc96LlXHWy91NwZTwcnwAOqSjYTEYPynyO-yrE',
								'abUi0tgJ_sT1zgvS9PEh-C_tcAGcX4O3Gutjx5sfdq8'] == 'reject') {
							wx.showModal({
								title: '订阅消息',
								content: '为更好的让您了解订单信息，服务号需要在您的订单操作时向您推送消息，您当前拒绝接受消息通知，是否去开启',
								confirmText: '开启授权',
								confirmColor: '#345391',
								cancelText: '仍然拒绝',
								cancelColor: '#999999',
								success(res) {
									if (res.confirm) {
										wx.openSetting({
											success(res) {},
											fail(err) {
												//失败
											}
										})
									} else if (res.cancel) {}
								}
							})
						}
					},
					fail: (errCode, errMessage) => {},
					complete: (errMsg) => {}

				});
			},
			//--------------------------------------------立即支付--------------------------------------------
			submitOrder() {
				uni.getStorage({
					key: 'userInfo',
					success: function(res) {
						_self.userInfo = res.data;
						if (!_self.$h.verify.isPhone(_self.phone)) {
							_self.$u.toast('请正确的手机号');
							return;
						}
						if (_self.ticketCheck.length == 0) {
							_self.showToast('请选择班次', 'warning');
						} else if (_self.personArr.length == 0) {
							_self.showToast('请选择乘车人', 'warning');
						} else if (_self.isCheckNotice == false) {
							// _self.showToast('请勾“选同意购票须知”', 'warning');
							_self.$u.toast('请勾选“同意购票须知”');
							_self.showNoticeContent();
						} else if (_self.phone == '') {
							// _self.showToast('请勾“选同意购票须知”', 'warning');
							_self.$u.toast('请填写手机号');
						} else {
							var setOutTime = _self.getTicketDate(_self.ticketCheck.SetoutTime);
							var pNumber = _self.adultNum + _self.childrenNum + _self.freeCount + _self
								.freeTicketNum;
							var fNumber = _self.freeTicketNum + _self.freeCount;
							var content = '班次时刻 : ' + setOutTime + '\r\n上车点 :【' + _self.ActualStartSiteName +
								'】\r\n下车点:【' + _self
								.ActualEndSiteName + '】\r\n乘车人数 : ' + pNumber;
							if (fNumber > 0) {
								content = content + '人,含携童' + fNumber + '人';
							} else {
								content += '人,无携童!';
							}
							uni.showModal({
								title: '订单信息核对',
								content: content,
								confirmText: '确定',
								cancelText: '取消',
								success(res) {
									if (res.confirm) {

										if (_self.PriceID.lastIndexOf('02') == _self.PriceID.length -
											2) {
											//保险班次，跳转保险告知
											_self.GetInsureInfoToPay();
										} else {
											//正常下单
											_self.GetFlowIdByParam();
										}
									}
								}
							})

						}
					},
					fail: function() {
						uni.$emit('getAuthorize', {
							data: '授权'
						});
					}
				})
			},
			GetInsureInfoToPay: function() {
				var StartSiteName = _self.ActualStartSiteName;
				var EndSiteName = _self.ActualEndSiteName;
				if (_self.startGeocoderAddress != '' && _self.ActualStartSiteName != _self.startGeocoderAddress) {
					StartSiteName = _self.ActualStartSiteName + ',' + _self.startGeocoderAddress;
				}
				if (_self.endGeocoderAddress != '' && _self.ActualEndSiteName != _self.endGeocoderAddress) {
					EndSiteName = _self.ActualEndSiteName + ',' + _self.endGeocoderAddress;
				}
				var fNumber = _self.freeTicketNum + _self.freeCount;
				var ComfirmParams = {
					StartSiteName: StartSiteName, //上车点
					EndSiteName: EndSiteName, //下车点
					PriceID: _self.PriceID, //票价ID
					PhoneNumber: _self.phone || _self.userInfo.PhoneNumber, //联系电话
					FullTicket: _self.adultNum, //全票
					HalfTicket: _self.childrenNum, //半票
					CarryChild: fNumber, //携童
					IDNameType: _self.idNameTypeStr, //乘车人字符串拼接
					BookType: _self.BookType, //下单类型：城际快车、汽车票
					StartSiteLoction: _self.StartSiteLoction, //上车点经纬度 格式:经度,纬度
					EndSiteLoction: _self.EndSiteLoction, //下车点经纬度 格式:经度,纬度
					LineName: _self.ticketCheck.LineName,
					ExecuteDate: _self.date,
					FullPrice: _self.Price,
					SetoutTimeDesc: _self.ActualStartTime,
					startStation: _self.ticketCheck.StationName,
					endStation: _self.ticketCheck.EndSiteName,
				}
				console.log('0000',ComfirmParams);
				uni.redirectTo({
					url: '/pages_IntercityExpress/subWebViewItem/InsureView?ComfirmParams=' + JSON
						.stringify(
							ComfirmParams)
				})
			},

			//--------------------------------------------下单--------------------------------------------
			GetFlowIdByParam: function() {
				//_self.sendTemMessage();
				var StartSiteName = _self.ActualStartSiteName;
				var EndSiteName = _self.ActualEndSiteName;
				if (_self.startGeocoderAddress != '' && _self.ActualStartSiteName != _self.startGeocoderAddress) {
					StartSiteName = _self.ActualStartSiteName + ',' + _self.startGeocoderAddress;
				}
				if (_self.endGeocoderAddress != '' && _self.ActualEndSiteName != _self.endGeocoderAddress) {
					EndSiteName = _self.ActualEndSiteName + ',' + _self.endGeocoderAddress;
				}
				var BookType = _self.BookType;
				// if (_self.isOtherSystemName != '') {
				// 	BookType = _self.BookType + ',' + _self.isOtherSystemName;
				// }
				uni.showLoading({
					title: '订单生成中...'
				});
				var fNumber = _self.freeTicketNum + _self.freeCount;
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetFlowIdByParam.url,
					method: _self.$h.expressInterface.expressInterface.GetFlowIdByParam.method,
					header: _self.$h.expressInterface.expressInterface.GetFlowIdByParam.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						ClientID: _self.userInfo.Id, //用户id
						ClientName: _self.userInfo.Name, //用户名
						ScheduleCompanyCode: _self.ticketCheck.CompanyCode,
						StartSiteName: StartSiteName, //上车点
						EndSiteName: EndSiteName, //下车点
						PriceID: _self.PriceID, //票价ID
						PhoneNumber: _self.phone || _self.userInfo.PhoneNumber, //联系电话
						FullTicket: _self.adultNum, //全票
						HalfTicket: _self.childrenNum, //半票
						CarryChild: fNumber, //携童
						IDNameType: _self.idNameTypeStr, //乘车人字符串拼接
						Insured: _self.isCheckInsurance, //保险
						OpenID: _self.openid,
						LineServicePrice: 0, //服务费
						Midway: false, //是否中途上车
						PlanCoachCardNumber: _self.ticketCheck.PlanCoachCardNumber,
						HotLine: _self.HotLine,
						BookType: BookType, //下单类型：城际快车、汽车票
						StartSiteLoction: _self.StartSiteLoction, //上车点经纬度 格式:经度,纬度
						EndSiteLoction: _self.EndSiteLoction, //下车点经纬度 格式:经度,纬度
						RecallId: _self.recallId,
					},
					success: (res) => {
						uni.hideLoading();
						//非空判断
						if (res.data.Success) {
							_self.flowID = res.data.Data;
							_self.GetRedictByFlowId(res.data.Data);
						} else {
							uni.showToast({
								title: '获取支付参数失败，请重试',
								icon: 'none'
							})
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------------获取车票支付参数--------------------------------------------
			GetRedictByFlowId: function(flowID) {
				uni.showLoading({
					title: '支付中请勿操作...',
					mask: true,
				});
				clearInterval(_self.timer)
				// var timer = null;
				// _self.timer = timer;
				_self.timer = setInterval(function() {
					uni.request({
						url: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.url,
						method: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.method,
						header: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.header,
						data: {
							flowID: flowID,
						},
						success: (res) => {
							console.log('支付参数', res);
							if (res.data.Success) {
								if (res.data.BookState == '支付系统申请支付订单') {
									uni.hideLoading();
									clearInterval(_self.timer);
									_self.paymentData = JSON.parse(res.data.Data);
									uni.showModal({
										content: '请在2分钟内完成支付',
										success(res) {
											if (res.confirm) {
												// #ifdef APP-PLUS
												_self.AppPayment();
												// #endif
												// #ifdef MP-WEIXIN
												console.log('支付参数', _self.paymentData);
												if (_self.paymentData.TokenID != null) {
													uni.navigateTo({
														url: '../../pages_IntercityExpress/subWebViewItem/weifutongPayview?name=在线支付' +
															'&tokenid=' + _self
															.paymentData.TokenID
													})
												} else {
													_self.WeChatPayment();
												}
												// #endif
											}else {
													_self.Cancle(_self.paymentData.FlowID);
												}
										}
									})
								}
							} else {
								if (res.data.BookState == '结束') {
									clearInterval(_self.timer);
									uni.hideLoading();
									if (res.data.Success) {
										_self.showToast(res.data.Message, 'success');
									} else {
										uni.showModal({
											title: '温馨提示',
											content: res.data.Message,
											success(res) {
												if (res.confirm) {}
											}
										})
										_self.showToast(res.data.Message, 'error');
									}

									// uni.showToast({
									// 	title: res.data.Message,
									// 	icon: 'none'
									// })
								} else {
									clearInterval(_self.timer);
									uni.showToast({
										title: '获取支付失败，请重试',
										icon: 'none'
									})
								}
							}
						},
						fail(res) {
							clearInterval(_self.timer);
							uni.hideLoading();
						}
					})
				}, 1000)
			},
			Cancle(aid) {
				uni.showLoading({
					title: '正在加载...'
				})  
				uni.request({
					url: _self.$h.expressInterface.expressInterface.Cancle.url,
					method: _self.$h.expressInterface.expressInterface.Cancle.method,
					header: _self.$h.expressInterface.expressInterface.Cancle.header,
					data: {
						booklogAID:aid,
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						if (res.data.Success) {
							_self.showToast('您已取消订单，如需购票请重新下单', 'warning');
						} else {
							//_self.showToast('支付失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//----------------------------------------APP支付----------------------------------------
			AppPayment: function() {
				uni.requestPayment({
					provider: 'wxpay',
					orderInfo: {
						appid: _self.paymentData.AppId,
						timestamp: _self.paymentData.TimeStamp,
						noncestr: _self.paymentData.NonceStr,
						package: 'Sign=WXPay',
						sign: _self.paymentData.PaySign,
						partnerid: _self.paymentData.PartnerId,
						prepayid: _self.paymentData.PrepayId,
					},
					success: function(res) {
						console.log('app支付结果', response)
						if (res.errMsg == 'requestPayment:ok') { //成功
							uni.showToast({
								title: '支付成功',
								icon: 'none'
							})
							_self.checkTicketTimer = setInterval(function() {
								//支付成功之后继续调获取支付参数的接口，查询订单状态
								_self.checkTicketState(_self.flowID);
							}, 4000)
						} else if (res.errMsg == 'requestPayment:fail errors') { //错误
							uni.showToast({
								title: '支付失败，请重新支付',
								icon: 'none'
							})
						} else if (res.errMsg == 'requestPayment:fail canceled') { //用户取消
							uni.showToast({
								title: '您取消了支付',
								icon: 'none'
							})
						}
					},

					fail: function(ee) {
						console.log(ee)
						uni.showToast({
							title: '拉起支付失败',
							icon: 'none',
							duration: 3000
						})
					}
				})
			},
			//----------------------------------------微信支付----------------------------------------
			WeChatPayment: function() {
				uni.requestPayment({
					provider: 'wxpay',
					timeStamp: _self.paymentData.TimeStamp,
					nonceStr: _self.paymentData.NonceStr,
					package: _self.paymentData.Package,
					signType: _self.paymentData.SignType,
					paySign: _self.paymentData.PaySign,
					success(res) {
						console.log(res)
						if (res.errMsg == "requestPayment:ok") {
							//标记支付成功
							var payInfo = {
								isSuccessPay: true,
								flowID: _self.flowID,
								recallId: _self.recallId,
								sequence: _self.sequence,
							}
							uni.setStorageSync('successPay', payInfo);
							uni.showToast({
								title: '支付成功',
								icon: 'none',
							})
							//保险业务跳转出票H5页面
							if (_self.recallId != '') {
								var CallbackParams = {
									flowID: _self.flowID,
									recallId: _self.recallId,
									sequence: _self.sequence,
								}
								uni.redirectTo({
									url: '/pages_IntercityExpress/subWebViewItem/BaseCallbackView?CallbackParams=' +
										JSON
										.stringify(
											CallbackParams)
								})

							} else {
								_self.checkTicketTimer = setInterval(function() {
									//支付成功之后继续调获取支付参数的接口，查询订单状态
									_self.checkTicketState(_self.flowID);
								}, 2000)
							}
						} else if (res.errMsg == "requestPayment:fail cancel") {
							setTimeout(function() {
								uni.showToast({
									title: '您取消了支付,如需购票请2分钟后再操作！',
									icon: 'none'
								})
							}, 1000)
						} else if (res.errMsg == "requestPayment:fail errors") {
							setTimeout(function() {
								uni.showToast({
									title: '支付失败，请重新支付',
									icon: 'none'
								})
							}, 1000)
						}
					},
					fail(res) {
						console.log(res)
						if (res.errMsg == "requestPayment:fail cancel") {
							setTimeout(function() {
								uni.showToast({
									title: '您取消了支付',
									icon: 'none'
								})
							}, 1000)
						} else if (res.errMsg == "requestPayment:fail errors") {
							setTimeout(function() {
								uni.showToast({
									title: '支付失败',
									icon: 'none'
								})
							}, 1000)
						} else {
							uni.showToast({
								title: '支付出错',
								icon: 'none'
							})
						}
					}
				});
			},
			//--------------------------------------------获取车票支付参数--------------------------------------------
			checkTicketState: function(flowID) {
				uni.showLoading({
					title: '正在确认支付状态...',
					mask: true,
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.url,
					method: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.method,
					header: _self.$h.expressInterface.expressInterface.GetRedictByFlowId.header,
					data: {
						flowID: flowID,
					},
					success: (res) => {
						console.log('支付参数', res);
						if (res.data.Success) {
							if (res.data.BookState == '结束' || res.data.BookState == '票务系统确认订单业务成功') {
								uni.hideLoading();
								clearInterval(_self.checkTicketTimer);
								if (res.data.Data != "") {
									_self.showToast(res.data.Message, 'success');
									setTimeout(function() {
										uni.switchTab({
											url: '../../pages/Order/Order'
										})
									}, 2000)
								} else {
									uni.showModal({
										title: '温馨提示',
										content: res.data.Message,
										success(res) {
											if (res.confirm) {}
										}
									})
									_self.showToast(res.data.Message, 'warning');
								}
							}
							// else {
							// 	clearInterval(_self.checkTicketTimer);
							// 	_self.showToast(res.data.Message,'error');
							// }
						} else {
							uni.hideLoading();
							clearInterval(_self.checkTicketTimer);
							_self.showToast(res.data.Message, 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
						clearInterval(_self.checkTicketTimer);
						uni.hideLoading();
					}
				})
			},
			change(e) {
				this.current = e;
			},
			//--------------------------------------返回--------------------------------------
			goBack() {
				uni.navigateBack();
			},
			//--------------------------------------选择乘客--------------------------------------
			selectPassage: function() {
				uni.navigateTo({
					url: '../../pages/Mine/Passenger/PassengerList'
				})
			},
			//--------------------------------------删除乘客--------------------------------------
			passageDelete: function(index) {
				_self.personArr.splice(index, 1);
				_self.countPassage(_self.personArr);
				uni.setStorageSync('personList', _self.personArr);
			},
			//--------------------------------------添加乘客--------------------------------------
			addPassage: function() {
				uni.getStorage({
					key: 'userInfo',
					success: function(res) {
						_self.userInfo = res.data;
						uni.navigateTo({
							url: '../../pages/Mine/Passenger/AddPassenger'
						})
					},
					fail: function() {
						uni.$emit('getAuthorize', {
							data: '授权'
						});
					}
				})

			},
			//--------------------------------------添加携童免票--------------------------------------
			addFreeChild: function() {
				//成人数为0，不可以携童

				if (_self.adultNum == 0) {
					_self.showToast('请先选择乘车人', 'warning');
				} else {
					//判断是否可携童
					if (_self.CarryChildAvaliable) {
						_self.showFreeChild = true;
						_self.GetTicketInstructionsMemo1();
						var adultArr = _self.personArr.filter(item => {
							return item.Type == '成人';
						})
						_self.freeMax = adultArr.length;
					} else {
						_self.showToast('该班次无可携童票数', 'warning');
					}
				}
			},
			//班次下拉选择
			ScheduleClike: function(index) {
				for (let i = 0; i < _self.shiftList.length; i++) {
					if (index == i) {
						_self.shiftList[i].checked = true;
					} else {
						_self.shiftList[i].checked = false;
					}
				}
			},
			//--------------------------------------选中车票--------------------------------------
			ticketTypeSelect: function(index, indexType) {
				console.log('000',_self.shiftList[index].SchedulesType[indexType].PriceID);
				if (_self.shiftList[index].SchedulesType[indexType].PriceID.lastIndexOf('02') != _self.shiftList[index]
					.SchedulesType[indexType].PriceID.length - 2) {
					console.log(_self.shiftList[index].SchedulesType[indexType].StationName, _self.shiftList[index]
						.SchedulesType[indexType].EndSiteName, _self.shiftList[index].SchedulesType[indexType]
						.SetoutTime, _self.shiftList[index].SchedulesType[indexType].PlanScheduleCode);
					uni.showLoading({
						title: '正在加载...'
					})
					uni.request({
						url: _self.$h.expressInterface.expressInterface.GetSchedulePrice.url,
						method: _self.$h.expressInterface.expressInterface.GetSchedulePrice.method,
						header: _self.$h.expressInterface.expressInterface.GetSchedulePrice.header,
						data: {
							appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode
								.appSystemCode,
							StartSite: _self.shiftList[index].SchedulesType[indexType].StationName,
							EndSite: _self.shiftList[index].SchedulesType[indexType].EndSiteName,
							ExecuteDate: _self.shiftList[index].SchedulesType[indexType].SetoutTime,
							PlanScheduleCode: _self.shiftList[index].SchedulesType[indexType].PlanScheduleCode,
						},
						success: (res) => {
							uni.hideLoading();
							var list = JSON.parse(res.data.Data);
							console.log('000', list);
							if (res.data.Success) {
								// _self.ticketCheck = list[0];
								console.log('选中车票', list[0]);
								_self.ticketCheck = list[0];
								console.log('选中车票', _self.ticketCheck);
							} else {
								_self.ticketCheck = _self.shiftList[index].SchedulesType[indexType];
								_self.showToast('加载失败，请稍后重试', 'warning');
							}
							_self.ticketCheckOne();
						},
						fail(res) {
							console.log('001', res);
							uni.hideLoading();
						}
					});
				} else {
					_self.ticketCheck = _self.shiftList[index].SchedulesType[indexType];
					_self.ticketCheckOne();
				}

			},
			ticketCheckOne: function() {
				_self.ActualStartTime = _self.timeFormat(_self.ticketCheck.SetoutTime);
				_self.EstimatedTime = _self.ticketCheck.EstimatedTime;
				_self.Price = _self.ticketCheck.FullPrice;
				_self.FullPrice = _self.ticketCheck.FullPrice;
				console.log('13222456', _self.ticketCheck);
				_self.HalfPrice = _self.ticketCheck.HalfPrice;
				_self.LinePrices = _self.ticketCheck.LinePrices;
				_self.PriceID = _self.ticketCheck.PriceID;
				_self.ActualEndSiteName = _self.ticketCheck.EndSiteName;
				console.log('00', _self.ActualEndSiteName);
				_self.ActualStartSiteName = _self.ticketCheck.StationName;
				if (!_self.isCheckInsurance) {
					console.log('getMyLocation');
					_self.getMyLocation();
				}
				_self.HotLine = _self.ticketCheck.HotLine;
				_self.CarryChildAvaliable = _self.ticketCheck.CarryChildAvaliable;
				_self.showTimePick = false;
				//_self.totalPrice = _self.ticketCheck.FullPrice;
				if (_self.ticketCheckPriceID != '') {
					_self.ActualStartSiteName = _self.params.StartSiteName;
					_self.ActualEndSiteName = _self.params.EndSiteName;
					_self.startGeocoderAddress = '';
					_self.endGeocoderAddress = '';
					let SiteNames = _self.params.StartSiteName.split(',');
					if (SiteNames.length > 1) {
						_self.ActualStartSiteName = SiteNames[0];
						_self.startGeocoderAddress = SiteNames[1];
					}
					console.log('12', _self.ActualStartSiteName);
					console.log('13', _self.ActualEndSiteName);
				}
				//计算总票价 
				console.log('bb113');
				_self.countTotalPrice();
				if (_self.ticketCheckPriceID != '') {
					//调起支付
					_self.GetFlowIdByParam();
					_self.ticketCheckPriceID = '';
				}



			},
			//--------------------------------------选中车票--------------------------------------
			ticketSelect: function(index) {
				console.log('aa33',index);
				for (let i = 0; i < _self.shiftList.length; i++) {
					if (index == i) {
						_self.shiftList[i].checked = true;
						uni.setStorage({
							key:'CheckIndex',
							data:index,
						})
						uni.showLoading({
							title: '正在加载...'
						})
						uni.request({
							url: _self.$h.expressInterface.expressInterface.GetSchedulePrice.url,
							method: _self.$h.expressInterface.expressInterface.GetSchedulePrice.method,
							header: _self.$h.expressInterface.expressInterface.GetSchedulePrice.header,
							data: {
								appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode
									.appSystemCode,
								StartSite: _self.shiftList[i].StationName,
								EndSite: _self.shiftList[i].EndSiteName,
								ExecuteDate: _self.shiftList[i].SetoutTime,
								PlanScheduleCode: _self.shiftList[i].PlanScheduleCode,
							},
							success: (res) => {
								uni.hideLoading();
								var list = JSON.parse(res.data.Data);
								if (res.data.Success) {
									for (let j = 0; j < list.length; j++) {
										if (list[j].PriceID.lastIndexOf('02') == list[j].PriceID.length - 2) {
											_self.isInsureType = true;
											_self.SchedulesType = list;
											break;
										}
									}
									_self.ticketCheck = list[0];
								} else {
									_self.ticketCheck = _self.shiftList[i];
									_self.showToast('加载失败，请稍后重试', 'warning');
								}
								_self.ActualStartSiteName = _self.ticketCheck.StationName;
								_self.ActualEndSiteName = _self.ticketCheck.EndSiteName;
								console.log('111', _self.ActualEndSiteName);
								
								_self.ActualStartTime = _self.timeFormat(_self.ticketCheck.SetoutTime);
								_self.EstimatedTime = _self.ticketCheck.EstimatedTime;
								_self.Price = _self.ticketCheck.FullPrice;
								_self.FullPrice = _self.ticketCheck.FullPrice;
								_self.HalfPrice = _self.ticketCheck.HalfPrice;
								_self.LinePrices = _self.ticketCheck.LinePrices;
								_self.PriceID = _self.ticketCheck.PriceID;
								_self.HotLine = _self.ticketCheck.HotLine;
								_self.CarryChildAvaliable = _self.ticketCheck.CarryChildAvaliable; //是否可以携童
								if (_self.ticketCheck.StartSites != null && _self.ticketCheck.StartSites
									.length > 1 && _self
									.recallId == '' || _self.ticketCheck.EndSites != null && _self
									.ticketCheck.EndSites
									.length > 1 && _self.recallId == '') {
									_self.getMyLocation();
								}
							},
							fail(res) {
								console.log('112', res);
								uni.hideLoading();
							}
						});


					} else {
						_self.shiftList[i].checked = false;
					}
				}
				//计算总票价
				_self.countTotalPrice();
			},
			getMyLocation: function() {
				//如果已经获取位置信息就不需要再去获取，微信接口有限制，频繁获取会导致接口无法调用
				if (_self.currentLongitude && _self.currentLatitude) {
					//乘客推荐上车点
					_self.GetStarSiteNameByLocation();
				} else {
					uni.getLocation({
						//type默认为wgs84返回gps坐标,gcj02返回国测局坐标,可用于uni.openLocation的坐标
						type: 'gcj02',
						geocode: 'true',
						success: function(res) {
							_self.currentLongitude = res.longitude;
							_self.currentLatitude = res.latitude;
							//乘客推荐上车点
							_self.GetStarSiteNameByLocation();
						},
						fail(res) {}
					});
				}
			},
			//--------------------------------------点击弹框的确认--------------------------------------
			ticketConfirm: function() {
				_self.showTimePick = false;
				if (_self.ticketCheck.length > 0) {
					console.log(_self.ticketCheck.FullPrice);
					_self.totalPrice = _self.ticketCheck.FullPrice;
				}
				if (_self.isInsureType && !_self.isCheckInsurance) {
					uni.showModal({
						title: '乘意险',
						content: '是否购买乘客意外伤害保险！',
						confirmText: '购买',
						cancelText: '取消',
						success(res) {
							if (res.confirm) {
								_self.isCheckInsurance = true;
								_self.insuranceSelect(false);
							}
						}
					})
				}
				//计算总票价
				_self.countTotalPrice();
			},
			insuranceSelect: function(isclick) {
				if (isclick) {
					_self.isCheckInsurance = !_self.isCheckInsurance;
				}
				if (_self.isCheckInsurance) {
					console.log('1a',_self.SchedulesType);
					console.log('1b',_self.PriceID);
					let isInsur = false;
					for (let j = 0; j < _self.SchedulesType.length; j++) {
						if (_self.SchedulesType[j].PriceID.lastIndexOf('02') == _self.SchedulesType[j].PriceID.length -
							2) {
							console.log(_self.SchedulesType[j].PriceID, _self.PriceID);
							if (_self.SchedulesType[j].PriceID == _self.PriceID + '02' || _self.SchedulesType[j]
								.PriceID == _self.PriceID) { 
									isInsur = true;
								_self.PriceID = _self.SchedulesType[j].PriceID;
								_self.totalPrice += _self.insurance * (_self.adultNum + _self.childrenNum);
							} 
						}
					}
					if(!isInsur){
							_self.showToast('当前上下车点未开通保险业务.', 'warning');
							_self.isCheckInsurance = !_self.isCheckInsurance;
					}
				} else {
					if (_self.PriceID.lastIndexOf('02') == _self.PriceID.length - 2) {
						_self.PriceID = _self.PriceID.substring(0, _self.PriceID.lastIndexOf('02'));
						_self.totalPrice -= _self.insurance * (_self.adultNum + _self.childrenNum);
					}

				}
			},
			//--------------------------------------乘客推荐上车点--------------------------------------
			GetStarSiteNameByLocation: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.url,
					method: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.method,
					header: _self.$h.expressInterface.expressInterface.GetStarSiteNameByLocation.header,
					data: {
						longitude: _self.currentLongitude,
						latitude: _self.currentLatitude,
						midwayLineSites: JSON.stringify(_self.ticketCheck.StartSites),
					},
					success: (res) => {
						uni.hideLoading();
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							_self.recommendGeton = res.data.Message;
							console.log(_self.ActualStartSiteName);
							_self.ActualStartSiteName = list.SiteName;
							console.log(_self.ActualStartSiteName);
							_self.startGeocoderAddress = '';
							_self.endGeocoderAddress = '';
							_self.changeTicketPrice();
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无推荐上车点信息',
								icon: 'none'
							})
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------计算价格--------------------------------------
			countTotalPrice: function() {
				if (_self.personArr.length > 0 && _self.ticketCheck) {
					var fullNum = 0;
					var halfNum = 0;
					for (let i = 0; i < _self.personArr.length; i++) {
						if (_self.personArr[i].Type == '成人') {
							fullNum++;
						} else if (_self.personArr[i].Type == '半票儿童') {
							halfNum++;
						}
					}
					_self.totalPrice = _self.FullPrice * fullNum + _self.HalfPrice * halfNum;
					_self.insuranceSelect(false);
				}
			},
			//--------------------------------------显示购票须知--------------------------------------
			showNoticeContent: function() {
				if (_self.isSBus) {
					_self.GetSchoolBusMemo();
				} else {
					_self.GetTicketInstructionsMemo();
				}
			},
			showInsureContent: function() {
				_self.GetInsureMemo();
			},
			//--------------------------------------加载购票须知--------------------------------------
			GetTicketInstructionsMemo: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('购票须知', res)
						if (res.data.Success) {
							_self.showNotice = true;
							_self.noticeContent = res.data.Data;
							console.log('须知须知', _self.noticeContent);
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			GetSchoolBusMemo: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetSchoolBusMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetSchoolBusMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetSchoolBusMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('购票须知', res)
						if (res.data.Success) {
							_self.showNotice = true;
							_self.noticeContent = res.data.Data;
							console.log('须知须知', _self.noticeContent);
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			GetInsureMemo: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetInsureMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetInsureMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetInsureMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						console.log('保险须知', res)
						if (res.data.Success) {
							_self.showNotice = true;
							_self.noticeContent = res.data.Data;
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------加载购票须知--------------------------------------
			GetTicketInstructionsMemo1: function() {
				uni.showLoading({
					title: '正在加载...'
				})
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.url,
					method: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.method,
					header: _self.$h.expressInterface.expressInterface.GetTicketInstructionsMemo.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						uni.hideLoading();
						// console.log('购票须知',res)
						if (res.data.Success) {
							// _self.showNotice = true;
							_self.noticeContent = res.data.Data;
							console.log('须知须知', _self.noticeContent);
						} else {
							_self.showToast('加载失败，请稍后重试', 'warning');
						}
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------记录用户操作--------------------------------------
			GetOperationLog: function(ExecuteDate) {
				var ScheduleLength = 0;
				if (_self.shiftList) {
					ScheduleLength = _self.shiftList.length;
				}
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetOperationLog.url,
					method: _self.$h.expressInterface.expressInterface.GetOperationLog.method,
					header: _self.$h.expressInterface.expressInterface.GetOperationLog.header,
					data: {
						StartSiteName: _self.ActualStartSiteName, //起点
						EndSiteName: _self.ActualEndSiteName, //终点
						PhoneNumber: _self.userInfo.PhoneNumber || _self.phone, //用户手机号
						BookType: _self.BookType, //下单类型：城际快车、汽车票
						ExecuteDate: ExecuteDate, //选择班次的日期
						ScheduleLength: ScheduleLength, //返回班次的长度
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
					},
					success: (res) => {
						// console.log('记录乘客操作返回数据', res);
					},
					fail(res) {
						// console.log('记录乘客操作返回数据', res);
					}
				});
			},
			//--------------------------------------客运加载班次列表数据--------------------------------------
			GetCoachInfoBySite: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({ //GetCoachInfoBySite//GetCoachInfoTypeBySite
					url: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.url,
					method: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.method,
					header: _self.$h.expressInterface.expressInterface.GetCoachInfoTypeBySite.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						StartSite: _self.startStation,
						EndSite: _self.endStation,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							for (let i = 0; i < list.length; i++) {
								var arr = {
									checked: false,
									StationName: list[i].StationName,
									EndSiteName: list[i].EndSiteName,
									FullPrice: list[i].FullPrice,
									HalfPrice: list[i].HalfPrice,
									FreeSeats: list[i].FreeSeats,
									SetoutTime: list[i].SetoutTime,
									PriceID: list[i].PriceID,
									LineName: list[i].LineName,
									CompanyCode: list[i].CompanyCode,
									// StartSites: list[i].StartSites,
									// EndSites: list[i].EndSites,
									StartSites: list[i].schedulesType[0].StartSites,
									EndSites: list[i].schedulesType[0].EndSites,
									PlanCoachCardNumber: list[i].PlanCoachCardNumber,
									LinePrices: list[i].LinePrices,
									HotLine: list[i].Memo,
									CarryChildAvaliable: list[i].CarryChildAvaliable,
									EstimatedTime: list[i].EstimatedTime,
									SchedulesType: list[i].schedulesType,
									Descript: list[i].Descript,
									CoachSeatNumber: list[i].CoachSeatNumber,
									PlanScheduleCode: list[i].PlanScheduleCode,
								}
								for (let j = 0; j < arr.SchedulesType.length; j++) {
									if (_self.ticketCheckPriceID != '') {
										console.log(arr.SchedulesType[j]);
										if (arr.SchedulesType[j].PriceID == _self.ticketCheckPriceID) {
											console.log(arr.SchedulesType[j].PriceID);
											// _self.ticketCheck = arr.SchedulesType[j];
											_self.ticketCheck = arr;
											_self.SchedulesType = arr.SchedulesType;
											_self.ticketCheckOne();
										}
									}
									//判定是否存在保险班次。
									// if (arr.SchedulesType[j].PriceID.lastIndexOf('02') == arr
									// 	.SchedulesType[j].PriceID.length - 2) {
									// }
								}
								_self.shiftList.push(arr);
								if (_self.isInsureType) {
									//_self.shiftList[0].checked = true;
								}

							}
							if (_self.shiftList.length > 0) {
								if (_self.ticketCheck != null) {
									_self.Price = _self.ticketCheck.FullPrice;
								} else {
									_self.Price = _self.shiftList[0].FullPrice;
								}
								if (_self.isInsureType) {
									//_self.shiftList[0].checked = true;
									uni.getStorage({
										key: 'CheckIndex',
										success: function(res) {
											console.log('aa11');
											_self.ticketSelect(res.data);
										},
										fail: function() {
											console.log('004');
										}
									})
								}
							}
						} else {
							_self.shiftList = [];
							uni.showToast({
								title: res.data.Message,
								icon: 'none'
							})
						}
						//记录用户操作
						console.log(1);
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------城际快车（有线路id）加载班次列表数据--------------------------------------
			GetScheduleByLineID: function(date, LineID) {
				uni.showLoading({
					title: '正在加载...'
				});
				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.url,
					method: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.method,
					header: _self.$h.expressInterface.expressInterface.GetScheduleByLineID.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						LineID: LineID,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							console.log('123', list);
							for (let i = 0; i < list.length; i++) {
								var arr = {
									checked: false,
									StationName: list[i].StationName,
									EndSiteName: list[i].EndSiteName,
									FullPrice: list[i].FullPrice,
									HalfPrice: list[i].HalfPrice,
									FreeSeats: list[i].FreeSeats,
									SetoutTime: list[i].SetoutTime,
									PriceID: list[i].PriceID,
									LineName: list[i].LineName,
									CompanyCode: list[i].CompanyCode,
									// StartSites: list[i].StartSites,
									// EndSites: list[i].EndSites,
									StartSites: list[i].schedulesType[0].StartSites,
									EndSites: list[i].schedulesType[0].EndSites,
									PlanCoachCardNumber: list[i].PlanCoachCardNumber,
									LinePrices: list[i].LinePrices,
									HotLine: list[i].Memo,
									CarryChildAvaliable: list[i].CarryChildAvaliable,
									EstimatedTime: list[i].EstimatedTime,
									SchedulesType: list[i].schedulesType,
									Descript: list[i].Descript,
									CoachSeatNumber: list[i].CoachSeatNumber,
									PlanScheduleCode: list[i].PlanScheduleCode,
								}
								for (let j = 0; j < arr.SchedulesType.length; j++) {
									if (_self.ticketCheckPriceID != '') {
										console.log(arr.SchedulesType[j]);
										if (arr.SchedulesType[j].PriceID == _self.ticketCheckPriceID) {
											console.log(arr.SchedulesType[j].PriceID);
											// _self.ticketCheck = arr.SchedulesType[j];
											_self.ticketCheck = arr;
											_self.SchedulesType = arr.SchedulesType;
											_self.ticketCheckOne();
										}
									}
									//判定是否存在保险班次。 
									// if (arr.SchedulesType[j].PriceID.lastIndexOf('02') == arr
									// 	.SchedulesType[j].PriceID.length - 2) {
									// 	_self.isInsureType = true;
									// }
								}
								_self.shiftList.push(arr);
								if (_self.isInsureType) {
									//_self.shiftList[0].checked = true;
									
								}

							}
							if (_self.shiftList.length > 0) {
								if (_self.ticketCheck != null) {
									_self.Price = _self.ticketCheck.FullPrice;
								} else {
									_self.Price = _self.shiftList[0].FullPrice;
								}
								if (_self.isInsureType) {
									//_self.shiftList[0].checked = true;
									uni.getStorage({
										key: 'CheckIndex',
										success: function(res) {
											console.log('aa22');
											_self.ticketSelect(res.data);
										},
										fail: function() {
											console.log('004');
										}
									})
								}
							}
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无班次信息',
								icon: 'none'
							})
						}
						//记录用户操作
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//--------------------------------------城际快车（无线路id）加载班次列表数据--------------------------------------
			GetScheduleByStarEndSite: function(date) {
				uni.showLoading({
					title: '正在加载...'
				});

				uni.request({
					url: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.url,
					method: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.method,
					header: _self.$h.expressInterface.expressInterface.GetScheduleByStarEndSite.header,
					data: {
						appSystemCode: _self.$h.expressInterface.expressInterface.appSystemCode.appSystemCode,
						StartSite: _self.startStation,
						EndSite: _self.endStation,
						ExecuteDate: date,
					},
					success: (res) => {
						uni.hideLoading();
						_self.shiftList = [];
						//非空判断
						if (res.data.Success) {
							var list = JSON.parse(res.data.Data);
							if (list.ScheduleInfos) {
								for (let i = 0; i < list.ScheduleInfos.length; i++) {
									var arr = {
										checked: false,
										StationName: list.ScheduleInfos[i].StationName,
										EndSiteName: list.ScheduleInfos[i].EndSiteName,
										FullPrice: list.ScheduleInfos[i].FullPrice,
										HalfPrice: list.ScheduleInfos[i].HalfPrice,
										FreeSeats: list.ScheduleInfos[i].FreeSeats,
										SetoutTime: list.ScheduleInfos[i].SetoutTime,
										PriceID: list.ScheduleInfos[i].PriceID,
										LineName: list.ScheduleInfos[i].LineName,
										CompanyCode: list.ScheduleInfos[i].CompanyCode,
										StartSites: list.ScheduleInfos[i].StartSites,
										EndSites: list.ScheduleInfos[i].EndSites,
										PlanCoachCardNumber: list.ScheduleInfos[i].PlanCoachCardNumber,
										LinePrices: list.ScheduleInfos[i].LinePrices,
										HotLine: list.ScheduleInfos[i].Memo,
										EstimatedTime: list.ScheduleInfos[i].EstimatedTime,
										CoachSeatNumber: list.ScheduleInfos[i].CoachSeatNumber,
										PlanScheduleCode: list.ScheduleInfos[i].PlanScheduleCode,
									}
									_self.shiftList.push(arr);
								}
								if (_self.shiftList.length > 0) {
									_self.Price = _self.shiftList[0].FullPrice;
								}
							}
						} else {
							_self.shiftList = JSON.parse(res.data.Data);
							uni.showToast({
								title: '暂无班次信息',
								icon: 'none'
							})
						}
						//记录用户操作
						console.log(3);
						_self.GetOperationLog(date);
					},
					fail(res) {
						uni.hideLoading();
					}
				});
			},
			//-----------------------------------显示时刻表-----------------------------------
			scheduleShow: function() {
				console.log('003');
				_self.showTimePick = true;
				if (_self.ticketCheck == []) {
					//请求班次信息_self.orderInfo.selectDate：上一个页面传过来的时间
					if (_self.BookType == '城际快车') {
						if (_self.LineID) {
							//请求班次数据(有线路id)
							_self.GetScheduleByLineID(_self.date, _self.LineID);
						} else {
							_self.GetScheduleByStarEndSite(_self.date);
						}
					} else {
						console.log(1);
						_self.GetCoachInfoBySite(_self.date);
					}
				}

			},
			//-----------------------------------拨打热线号码-----------------------------------
			HotLineClick: function(phoneNum) {
				uni.makePhoneCall({
					phoneNumber: phoneNum
				})
			},
			//-----------------------------------点击时间选项卡的时间-----------------------------------
			dateClick: function(e, item) {
				console.log('002', e);
				_self.selectIndex = e;
				_self.date = item.longDate;
				if (_self.BookType == '城际快车') {
					if (_self.LineID) {
						//请求班次数据(有线路id)
						_self.GetScheduleByLineID(_self.date, _self.LineID);
					} else {
						_self.GetScheduleByStarEndSite(_self.date);
					}
				} else {
					_self.GetCoachInfoBySite(_self.date);
				}
			},
			//-----------------------------------显示日历-----------------------------------
			onShowDatePicker: function(type) {
				//先隐藏时刻表，再显示日历（由于层级问题，日历不会显示到最上层，所以显示日历的时候需要先隐藏时刻表）
				_self.showTimePick = false;
				_self.$refs.calendar.open();
			},
			//---------------------------------日期确定---------------------------------
			confirm(params) {
				//在日历确定了时间之后先隐藏日历，再显示时刻表（由于层级问题，日历不会显示到最上层，所以显示日历的时候需要先隐藏时刻表）
				_self.dateShow = false;
				_self.showTimePick = true;
				_self.onSelected(params.fulldate);
			},
			//-----------------------------------选择日期-----------------------------------
			onSelected(calSelectDate) {
				console.log('001', calSelectDate);
				if (calSelectDate) {
					var selectDate = calSelectDate.replace(/-/g, '/');
					//从日历选择时间后刷新列表数据
					// _self.getTicketInfo(e.value);
					var IsExist = false;
					for (var i = 0; i < _self.dateArray.length; i++) {
						if ((new Date(_self.dateArray[i].longDate)).getTime() == (new Date(selectDate)).getTime()) {
							IsExist = true;
							_self.selectIndex = i;
							_self.scrollToView = '';
							if (i <= 1) {
								_self.scrollToView = 'view' + (i - 1);
							} else if (i > 6) {
								_self.scrollToView = 'view' + (i + 1);
							} else {
								_self.scrollToView = 'view' + i;
							}
						}
					}
					//判断时间轴上是否存在改日期，不存在则重新绘制
					if (!IsExist) {
						_self.dateArray = [];
						var dateToday = new Date(); //获取今天日期
						var date = new Date(selectDate); //选中的日期
						_self.selectIndex = 0;
						for (var i = 0; i < 8; i++) {
							var mydate = new Date(date.getTime() + 24 * i * 60 * 60 * 1000); //日期一天加一次
							var nowdate = _self.getTime(3, mydate); //获取该日期的缩写  月/日
							var week = _self.getTime(2, mydate); //获取该日期为周几
							var longdate = _self.getTime(0, mydate); //获取 年/月/日
							if (_self.getTime(0, mydate) == _self.getTime(0, dateToday)) {
								week = '今天';
							}
							_self.dateArray.push({
								week: week,
								date: nowdate,
								longDate: longdate,
							});
						}
					}
					_self.date = calSelectDate;
					if (_self.BookType == '城际快车' && _self.ticketCheckPriceID == '') {
						if (_self.LineID) {
							//请求班次数据(有线路id)
							console.log('bbbbbbbbbbb');
							_self.GetScheduleByLineID(_self.date, _self.LineID);
						} else {
							//请求班次数据(无线路id)
							_self.GetScheduleByStarEndSite(_self.date);
						}
					} else if (_self.BookType == '校园直通车') {
						_self.isSBus = true;
						_self.GetCoachInfoBySite(_self.date);

					} else {
						_self.GetCoachInfoBySite(_self.date);
					}

				}
			},
			//-----------------------------------初始化时间轴-----------------------------------
			loadDate() {
				var date = new Date();
				_self.selectIndex = 0;
				for (var i = 0; i < 8; i++) {
					var mydate = new Date(date.getTime() + 24 * i * 60 * 60 * 1000);
					var nowdate = _self.getTime(3, mydate);
					var week = _self.getTime(2, mydate);
					var longdate = _self.getTime(0, mydate);
					if (mydate.getTime() == date.getTime()) {
						week = '今天';
					}
					_self.dateArray.push({
						week: week,
						date: nowdate,
						longDate: longdate,
					});
				}
			},
			//日期时间转换函数   type 0 年月日 ，1 时分秒 ， 2 星期 ，3 月/日  4几月几日
			getTime: function(type, date1) {
				let date = new Date(date1.getTime()),
					currentDate,
					currentTime,
					sortDate,
					monthAndDay,
					seperator = "/", // 如果想要其他格式 只需 修改这里 
					year = date.getFullYear(),
					month = date.getMonth() + 1,
					weex = date.getDay(),
					day = date.getDate(),
					hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
					minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
					second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// month >= 1 && month <= 9 ? (month = "0" + month) : "";
				// day >= 0 && day <= 9 ? (day = "0" + day) : "";
				//当前 日期
				currentDate = year + seperator + month + seperator + day;
				//当前 时间
				currentTime = hour + ":" + minute + ":" + second;
				sortDate = month + "/" + day;
				monthAndDay = month + "月" + day + "日";
				// 输出格式 为 2018-8-27 14:45:33
				if (type == 0) {
					return currentDate
				} else if (type == 1) {
					return currentTime;
				} else if (type == 2) {
					if (weex == 1) {
						return '周一'
					}
					if (weex == 2) {
						return '周二'
					}
					if (weex == 3) {
						return '周三'
					}
					if (weex == 4) {
						return '周四'
					}
					if (weex == 5) {
						return '周五'
					}
					if (weex == 6) {
						return '周六'
					}
					if (weex == 0) {
						return '周日'
					}
				} else if (type == 3) {
					return sortDate;
				} else if (type == 4) {
					return monthAndDay;
				} else {
					return currentDate + " " + currentTime;
				}
			},
		}
	};
</script>

<style>
	.mg-top-20 {
		margin-top: 20rpx;
	}

	.mg-top-40 {
		margin-top: 40rpx;
	}

	.border-r-20 {
		border-radius: 20rpx;
	}

	.border-r-8 {
		border-radius: 8rpx;
	}

	.v-name {
		border: solid 1rpx #4481eb;
		color: #4481eb;
		padding: 5rpx 20rpx;
		margin-right: 20rpx;
	}

	.v-type {
		background-color: #e3f3ff;
		color: #4481eb;
		padding: 5rpx 8rpx;
		margin-left: 15rpx;
		font-size: 24rpx;
	}

	.checkbox {
		width: 50rpx;
		height: 50rpx;
		border: solid 1rpx #999;
		border-radius: 100%;
		text-align: center;
		line-height: 45rpx;
		/* position: fixed; */
		/* right: 60rpx; */
	}

	.defaultPay {
		background: linear-gradient(270deg, #95a5a6, #ecf0f1);
	}

	.checkbox-activite {
		background: linear-gradient(270deg, #ef7d4e, #ec5249);
		border-color: #ec5249;
	}

	.circle-blue {
		width: 20rpx;
		height: 20rpx;
		border-radius: 100%;
		background-color: #19A0FF;
	}

	.circle-blue-small {
		width: 15rpx;
		height: 15rpx;
		border-radius: 100%;
		background-color: #A2D9FF;
	}

	.headerClass {
		width: 100%;
		background: #FFFFFF;
		height: 109rpx;
		margin-bottom: 10rpx;
		display: flex;
	}

	.scrollClass {
		height: 109rpx;
		width: 86%;
		/* 外层写这俩 */
		white-space: nowrap;
		flex-wrap: nowrap;
	}

	.blockClass {
		margin: 12rpx 14rpx;
		/* background: #FFFFFF; */
		width: 87rpx;
		height: 84rpx;
		border-radius: 8rpx;
		/* 里层写这个 */
		display: inline-block;
	}

	.textCLass {
		margin: 9rpx 17rpx;
	}

	.weekClass {
		/* display: block; */
		/* font-size: 26rpx; */
		font-family: MicrosoftYaHei;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}

	.calendarImage {
		width: 35rpx;
		height: 37rpx;
	}

	.dateClass {
		/* display: block; */
		font-size: 24rpx;
		font-family: MicrosoftYaHei;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}

	.dateselect {
		background: linear-gradient(270deg, #ef7d4e, #ec5249);
	}

	.weekClass {
		color: #FFFFFF;
	}

	.dateClass {
		color: #FFFFFF;
	}
</style>